package com.neu.controller;

import com.neu.dto.CustomerDTO;
import com.neu.service.CustomerService;
import com.neu.utils.ResultModel;
import com.neu.vo.CustomerVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/customer")
public class CustomerController {
    @Autowired
    CustomerService customerService;
    /**
     * 用户登录
     * @param name
     * @param password
     * @return
     */
    @PostMapping("/login")
    public ResultModel login(String name,String password){
        ResultModel resultModel=new ResultModel();
        CustomerVO customerVO=customerService.login(name,password);
        if(customerVO==null){
            resultModel.setMsg("登录失败");
            resultModel.setCode(500);
        }
        else{
            resultModel.setData(customerVO);
            resultModel.setMsg("登录成功");
            resultModel.setCode(200);
        }
        return resultModel;
    }

    /**
     * 用户注册
     * @param customerDTO
     * @return
     */
    @PostMapping("/register")
    public ResultModel register(CustomerDTO customerDTO){
        ResultModel resultModel=new ResultModel();
        return  resultModel;
    }
}
